﻿<?
//======================================================
//Conectar
//======================================================
include "conexao.php";
@session_start(); // Inicializa a sessão
connect();
//======================================================
// Valores
//======================================================
$txtidprocesso = $_POST["txtidprocesso"];
$txtfolha = $_POST["txtfolha"];
$txtvolume = $_POST["txtvolume"];
$txtdata = $_POST["txtdata"];

//======================================================
//Inserir
//======================================================
if ($_POST[gravar] == "gravar")
{

$consulta = "INSERT INTO volume
		(id_processo,volume,folhas,data_criacao)
		VALUES
		('$txtidprocesso', '$txtvolume','$txtfolha','$txtdata')";
		mysql_query("SET NAMES 'utf8'");
		mysql_query('SET character_set_connection=utf8');
		mysql_query('SET character_set_client=utf8');
		mysql_query('SET character_set_results=utf8');	
 $resultado = mysql_query($consulta);  
?>
<script language="JavaScript">
	alert ("Volume Cadastrado!!");
</script>
<script language="JavaScript">
	window.location.assign("lista_volume.php?idprocesso=<?echo $txtidprocesso ?>");
</script>
<?
} 
//======================================================
//Alterar
//======================================================
if ($_POST[atualizar] == "atualizar")
{
 $consulta = "UPDATE emepenho SET 
			  emepenho =  '$txtcodempenho',
			  fornecedor_codfornecedor = '$txtfornecedor',
			  ativo = '$cmbativo'
			 WHERE codempenho = '$txtcodempenho'";
		 mysql_query("SET NAMES 'utf8'");
		 mysql_query('SET character_set_connection=utf8');
		 mysql_query('SET character_set_client=utf8');
		 mysql_query('SET character_set_results=utf8');			 
 $resultado = mysql_query($consulta);  
 include "validaerrobanco.php";
?>
<script language="JavaScript">
	alert ("Salvo");
</script>
<script language="JavaScript">
	window.location.assign("../listagemempenho.php");
</script>
<?
}
?>